﻿Public Class KNNhanVien
    Private dt As New Database_
    Private sql As String
    Private DS As New List(Of DTO_NhanVienCT.NhanVien)
    Private nv As DTO_NhanVienCT.NhanVien
    Public Function DSNV() As DataTable
        sql = "select * from NHANVIEN"
        Dim data As DataTable = dt.execQuery(sql)
        Return data
    End Function
    Public Function SaveNV(ByVal data As DataTable) As Boolean
        sql = "select * from NHANVIEN "
        Return dt.ExecUpdate(sql, data)
    End Function
    Public Function DSNhanVien() As List(Of DTO_NhanVienCT.NhanVien)
        sql = "select nv.MaNV, nv.HoTen from NHANVIEN nv"
        Dim data As DataTable = dt.execQuery(sql)
        For Each dr As DataRow In data.Rows
            nv = New DTO_NhanVienCT.NhanVien
            nv.MaNV = dr("MaNV")
            nv.HoTen = dr("HoTen")
            DS.Add(nv)
        Next
        Return DS
    End Function
    Public Function DKDSNV(ByVal str As String) As DataTable
        sql = "select * from NHANVIEN n where n.MaPhong='" & str & "'"
        Dim data As DataTable = dt.execQuery(sql)
        Return data
    End Function
    Public Function DSNVDK(ByVal manv As String) As List(Of DTO_NhanVienCT.NhanVien)
        sql = "select nv.MaNV, nv.HoTen, nv.CVu, nv.QTich, nv.NgaySinh, nv.CMND, nv.NgayCap, nv.NoiCap, nv.DienThoai, nv.DCTTru from NHANVIEN nv where nv.MaNV='" & manv & "'"
        Dim data As DataTable = dt.execQuery(sql)
        For Each dr As DataRow In data.Rows
            nv = New DTO_NhanVienCT.NhanVien
            nv.MaNV = dr("MaNV")
            nv.HoTen = dr("HoTen")
            nv.ChucVu = dr("CVu")
            nv.QuocTich = dr("QTich")
            nv.NgaySinh = dr("NgaySinh")
            nv.CMND = dr("CMND")
            nv.NgayCap = dr("NgayCap")
            nv.NoiCap = dr("NoiCap")
            nv.DienThoai = dr("DienThoai")
            nv.DiaChi = dr("DCTTru")
            DS.Add(nv)
        Next
        Return DS
    End Function
End Class
'Private DSNV As List(Of DTO_NhanVienCT.NhanVien)
'Private sql As String
'Private data As New Database_
'Private nv As DTO_NhanVienCT.NhanVien
'Public Function DSNhanVien() As List(Of DTO_NhanVienCT.NhanVien)
'    DSNV = New List(Of DTO_NhanVienCT.NhanVien)
'    sql = "select * from NHANVIEN"
'    Dim dt As DataTable = data.execQuery(sql)
'    For Each dr As DataRow In dt.Rows
'        nv = New DTO_NhanVienCT.NhanVien
'        nv.MaNV = dr("MaNV")
'        nv.HoTen = dr("HoTen")
'        nv.NgaySinh = dr("NgaySinh")
'        nv.GioiTinh = dr("GioiTinh")
'        nv.NoiSinh = dr("NoiSinh")
'        nv.NguyenQuan = dr("NguyenQuan")
'        nv.CMND = dr("CMND")
'        nv.NgayCap = dr("NgayCap")
'        nv.NoiCap = dr("NoiCap")
'        nv.DienThoai = dr("DienThoai")
'        nv.DiaChi = dr("DCTTru")
'        nv.DanToc = dr("DanToc")
'        nv.TonGiao = dr("TonGiao")
'        nv.HocVan = dr("TrinhDoHocVan")
'        nv.BangCap = dr("BangCap")
'        nv.NgoaiNgu = dr("NgoaiNgu")
'        nv.VaoDoan = dr("Doan")
'        nv.VaoDang = dr("Dang")
'        nv.QTBanThan = dr("TTBThan")
'        nv.BoPhan = dr("MaPhong")
'        nv.Hinh = dr("Hinh")
'        DSNV.Add(nv)
'    Next
'    Return DSNV
'End Function